import request from '@/utils/request'
var group_name = 'blog'
export default {
  save(blog) { // 添加
    return request({
      url: `/${group_name}/save`,
      method: 'post',
      data: blog
    })
  },
  getAllBlogsUndeletedAndEnabled() {
    return request({
      url: `/${group_name}/getAllBlogsUndeletedAndEnabled`,
      method: 'get'
    })
  },
  getByPage(page) { // 分页查询
    return request({
      url: `/${group_name}/getByPage`,
      method: 'post',
      data: page
    })
  },
  update(blog) { // 更新
    return request({
      url: `/${group_name}/update`,
      method: 'put',
      data: blog
    })
  },
  deleteById(id) { // 删除
    return request({
      url: `/${group_name}/delete/${id}`,
      method: 'delete'
    })
  },
  deleteByIds(ids) { // 删除
    return request({
      url: `/${group_name}/deleteByIds`,
      method: 'delete',
      data: ids
    })
  },
  get(id) { // 根据id查询
    return request({
      url: `/${group_name}/get/${id}`,
      method: 'get'
    })
  },
  getTimeLine(username) {
    return request({
      url: `/${group_name}/getTimeLine?username=${username}`,
      method: 'get'
    })
  },
  uploadImg(data) {
    return request({
      url: `/upload/uploadCover`,
      method: 'post',
      data: data
    })
  },
  deleteImage(data) { // 删除图片
    return request({
      url: `/upload/deleteImage`,
      method: 'delete',
      data: data,
      contentType: 'application/x-wwww-form-urlencoded'
    })
  },
  publish(data) { // 发布
    return request({
      url: `/${group_name}/publish/${data}`,
      method: 'get'
    })
  },
  back(data) { // 撤回到保存
    return request({
      url: `/${group_name}/back/${data}`,
      method: 'get'
    })
  },
  saveSubmit(data) { // 保存并提交
    return request({
      url: `/${group_name}/saveSubmit`,
      method: 'post',
      data: data
    })
  },
  hotExecute(type, blogId) {
    return request({
      url: `/${group_name}/hotExecute?type=${type}&blogId=${blogId}`,
      method: 'get'
    })
  }
}
